let s = '([{}])'

var isValid = function (s) {
    if (s.length % 2 !== 0) {
        return false
    }

    const leftToRight = {
        '(': ')',
        '[': ']',
        '{': '}'
    }
    let stack = []

    for (let i = 0; i < s.length; i++) {
        if (s[i] == '(' || s[i] == s[i] == '{}') {
            stack.push(leftToRight[i])
        } else {
            let r = s[i]
            let top = stack.pop()
            if (r !== top) {
                return false
            }
        }
    }
    return !stack.length
}



